package puzzle_game.test;

import java.util.Random;

public class test {
    // 随机打乱一维数组 并且把打乱的一位数组 四个一组放到二维数组中
    public static void main(String[] args) {
        int[] temparr = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
        Random r = new Random();
        for (int i = 0; i < temparr.length; i++) {
            int index = r.nextInt(temparr.length);
            int temp = temparr[i];
            temparr[i] = temparr[index];
            temparr[index] = temp;
        }
        for (int i = 0; i < temparr.length; i++) {
            System.out.print(temparr[i] + " ");
        }

        int[][] date = new int[4][4];
        int index = 0;
        for (int i = 0; i < date.length; i++) {
            for (int j = 0; j < date[i].length; j++) {
                date[i][j] = temparr[index];
                index++;
            }
        }

        System.out.println();
        for (int i = 0; i < date.length; i++) {
            for (int j = 0; j < date[i].length; j++) {
                System.out.print(date[i][j] + " ");
            }
            System.out.println();
        }

    }

}
